//联合类型
{
    let myFavoriteNumber: string|number ;
    myFavoriteNumber = 4;
    myFavoriteNumber = "aa"
}
function getString(something: string|number): string {
        return something.toString()
}
console.log(getString(123)) 
console.log(123) 

// 联合类型的变量在被赋值的时候，会根据类型推论的规则推断出一个类型：
let num1: string|number;
num1 = "xxx"
num1 = 22;
console.log(num1.length)